<?php
/**
* Profile
*/
class Profile {
	 private $pid;
	 private $username;
	 private $isLoggedIn;
	 private $email;
	 private $fname;
	 private $lname;
	 private $clubs;

	 public function __construct() {
			 $CI =& get_instance();
			 $this->isLoggedIn = $CI->phpsession->get("logged_in");
			 if($this->isLoggedIn) {
					 $this->username = $CI->phpsession->get("username");
					 $query = $CI->db->query("SELECT profile.p_id,username,forum_username,aha_number,fname,lname,email FROM profile,users,contact WHERE users.p_id=profile.p_id AND profile.contact_id=contact.contact_id AND users.username=?", array($this->username));
					 foreach ($query->result() as $row) {
							 $this->email = $row->email;
							 $this->fname = $row->fname;
							 $this->lname = $row->lname;
							 $this->pid = $row->p_id;
						 }
					 $query = $CI->db->query("SELECT club_id FROM club_affiliation WHERE p_id=?", array($this->pid));
					 foreach ($query->result() as $row) {
							 $this->clubs[] = $row->club_id; // grab all clubs person is affliiated with
						 }
				 
				 }
		 }
	 private function getProfile() {
		 
		 }
	 public function hasClubs(){
			 return (count($this->clubs)>0);
		 }
	 public function getClubs() {
			 return $this->clubs;
		 }
	 public function isLoggedIn() {
			 return $this->isLoggedIn;
		 }
	 public function getFirstName() {
			 return $this->fname;
		 }
	 public function setLoggedIn($val){
			 $this->isLoggedIn = $val;
		 }
}
?>